package pld.car.action;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import pld.car.bean.NewsImg;
import pld.car.bean.SettingsImg;

public class ImgAction extends BaseAction {

	private InputStream imageStream;

	private int imgID;

	public ImgAction() {
		System.out.println("ImgAction init!");
	}

	public String loadImgByID() throws IOException {
		try {
			NewsImg ni = this.getNewsService().findNewsImgByID(this.getImgID());
			byte[] img = ni.getImg();
			// File 转 InputStream
			this.imageStream = new ByteArrayInputStream(img);
		} catch (Exception e) {

		} finally {
			
		}
		return "success";
	}
	
	public String loadSettingsImgByID() throws IOException {
		try {
			SettingsImg si = this.getSettingsService().findSettingsImgByID(this.getImgID());
			byte[] img = si.getImg();
			// File 转 InputStream
			this.imageStream = new ByteArrayInputStream(img);
		} catch (Exception e) {

		} finally {
			
		}
		return "success";
	}

	public InputStream getImageStream() {
		return imageStream;
	}

	public void setImageStream(InputStream imageStream) {
		this.imageStream = imageStream;
	}

	public int getImgID() {
		return imgID;
	}

	public void setImgID(int imgID) {
		this.imgID = imgID;
	}

}
